package com.anxin.act.process.web;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.ReactiveTransaction;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anxin.framework.aspectj.lang.annotation.Log;
import com.anxin.framework.aspectj.lang.enums.BusinessType;
import com.anxin.act.process.entity.WfMenuProcess;
import com.anxin.act.process.service.WfMenuProcessService;
import com.anxin.framework.web.controller.BaseController;
import com.anxin.framework.web.entity.AjaxResult;
import com.anxin.framework.web.page.TableDataInfo;

/**
 * 菜单流程配置Controller
 *
 * @author jbs
 * @date 2020-03-10
 */
@RestController
@RequestMapping("/process/wfMenuProcess")
public class WfMenuProcessController extends BaseController{
    @Autowired
    private WfMenuProcessService wfMenuProcessService;

    /**
     * 查询菜单流程配置列表
     */
    @PreAuthorize("@ss.hasPermi('act:process:view')")
    @GetMapping("/list")
    @Log(title = "查询菜单流程配置列表", businessType = BusinessType.LIST)
    public TableDataInfo list(WfMenuProcess wfMenuProcess){
        startPage();
        List<WfMenuProcess> list = wfMenuProcessService.findList(wfMenuProcess);
        return getDataTable(list);
    }

    /**
     * 获取菜单流程配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('act:process:view')")
    @GetMapping(value = "/{id}")
    @Log(title = "获取菜单流程配置详细信息", businessType = BusinessType.LIST)
    public AjaxResult getInfo(@PathVariable("id") String id){
        return AjaxResult.success(wfMenuProcessService.getById(id));
    }

    /**
     * 保存菜单流程配置
     */
    @PreAuthorize("@ss.hasPermi('act:process:edit')")
    @Log(title = "菜单流程配置", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody WfMenuProcess wfMenuProcess){
        return toAjax(wfMenuProcessService.save(wfMenuProcess));
    }


    /**
     * 删除菜单流程配置
     */
    @PreAuthorize("@ss.hasPermi('act:process:remove')")
    @Log(title = "菜单流程配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable(("id")) String id){
        return toAjax(wfMenuProcessService.deleteById(id));
    }


    /**
     * 根据菜单标识获取流程标识
     * @param menuKey
     * @return
     */
    @GetMapping("/getProcessKey/{menuKey}")
    @Log(title = "根据菜单标识获取流程标识", businessType = BusinessType.LIST)
    public AjaxResult getProcessKey(@PathVariable(("menuKey")) String menuKey){
        return wfMenuProcessService.getProcessKey(menuKey);
    }

    /**
     * 根据菜单标识获取流程标识(没有默认值)
     * @param menuKey
     * @return
     */
    @GetMapping("/getMenuProcess/{menuKey}")
    public AjaxResult getMenuProcess(@PathVariable(("menuKey")) String menuKey){
        return AjaxResult.setSuccessData(wfMenuProcessService.getMenuProcess(menuKey));
    }

}
